<html>
<head>
    <title>NB-loT数据平台</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

     <link href="B-JUI/themes/css/bootstrap.css" rel="stylesheet">
    <link href="B-JUI/themes/css/style.css" rel="stylesheet">
    <link href="B-JUI/themes/blue/core.css" id="bjui-link-theme" rel="stylesheet">
    <link href="B-JUI/themes/css/fontsize.css" id="bjui-link-theme" rel="stylesheet"> 
    <link rel="stylesheet" type="text/css" href="/stylesheets/login.css">
    <link href="B-JUI/themes/css/FA/css/font-awesome.min.css" rel="stylesheet">
    <script src="B-JUI/js/jquery-1.11.3.min.js"></script>
    <script src="B-JUI/js/bjui-all.min.js"></script>
    <script src="B-JUI/plugins/bootstrap.min.js"></script>
    <script src="javascripts/des.js"></script>
    <script type="text/javascript">
        /**
         * 解决IE下不支持placeholder属性
         * author : MR chen  370489175@qq.com
         * Date: 16-01-19
         * 可以根据自己的需要去扩展
         * ps:写的很简单  根据自己的需求来  不喜勿喷
         */
        ;(function ($) {                            //兼容ie8的placeholder
            $.fn.placeholder = function (options) {
                var opts = $.extend({}, $.fn.placeholder.defaults, options);
                var isIE = document.all ? true : false;
                return this.each(function () {
                    var _this = this,
                            placeholderValue = _this.getAttribute("placeholder"); //缓存默认的placeholder值
                    if (isIE) {
                        _this.setAttribute("value", placeholderValue);
                        _this.onfocus = function () {
                            $.trim(_this.value) == placeholderValue ? _this.value = "" : '';
                        };
                        _this.onblur = function () {
                            $.trim(_this.value) == "" ? _this.value = placeholderValue : '';
                        };
                    }
                });
            };
        })(jQuery);
    </script>
</head>
<body>
<div class="login-interface">
    <div class="content">
        <div class="content-top">
            <p class="chinese-name">NB-loT数据平台</p>
        </div>
        <form class="content-bottom">
            <table>
                <tbody>
                <tr>
                    <td class="td-first-child"><span>账<span style="padding-left: 14px;"></span>号：</span></td>
                    <td class="td-last-child"><input id="username" type="text"  name="" style="float: left" placeholder="请输入账号" autocomplete="off"></td>
                </tr>
                <tr>
                    <td class="td-first-child"><span>密<span style="padding-left: 14px;"></span>码：</span></td>
                    <td class="td-last-child"><div><input id="password" type="password"  name="" style="float: left" placeholder="请输入密码" autocomplete="off" ></div></td>
                </tr>
                <tr>
                    <td class="td-first-child"><span>验证码：</span></td>
                    <td class="td-last-child">
                        <div class="verification-code">
                            <input id="imagecode" type="text" name="" placeholder="请输入验证码" autocomplete="off">
                            <div>
                                 <img id="getcode" onclick="get_img_code()"  style="width: 100%;height: 100%; background: #fff;" alt="验证码"/>
                            </div>
                        </div>

                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <button onclick="Dologin();return false;">确认</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>




<script type="text/javascript">
    $(document).ready(function(){
        if(window.location.pathname=='/'){
            location.reload();
             // location.href();
        }
        changeHeight();
        get_img_code();
    })
    $(window).resize(function(){
        changeHeight();
    });
    function changeHeight(){
        var winHeight=0;
        if (window.innerHeight){
            winHeight = window.innerHeight;
        }else if ((document.body) && (document.documentElement.clientHeight)){
            winHeight = document.documentElement.clientHeight;
        }
        var topheight = winHeight/2 - 180;
        $('.content').attr("style", "top:" + topheight+'px');
    }

    $("input").placeholder();
    function get_img_code(){
        var img = document.getElementById("getcode");
        var randomnum = Math.random();
        img.src="/account/getVerifyimg?"+randomnum;
    }
    function Dologin() {
        var username = $('#username').val();
        var password = $('#password').val();
        var imagecode = $('#imagecode').val();
        if (username == "") {
            BJUI.alertmsg('info', "请输入登录帐号");
            return;
        }
        if (password == "") {
            BJUI.alertmsg('info', "请输入登录密码");
            return;
        }
        // if (imagecode == "") {
        //     BJUI.alertmsg('info', "请输入验证码");
        //     return;
        // }
        $.ajax({
                 type: "post",
                 async: false,
                 url: "/login",
                 dataType:'json',
                 "data":{
                    "usercode":username,
                    "pwd":strEnc(username+','+password+','+imagecode,1,2,3),
                    'vcode':imagecode
                 },
                 success:function(msg){
                    if(msg.statusCode=="200"){
                        location.href = "/";
                    }else{
                        BJUI.alertmsg('info', msg.message);
                        get_img_code();
                        $('#imagecode').val('');
                    }
                 },
                 error:function(XMLHttpRequest, textStatus, errorThrown){
                    if(XMLHttpRequest.status){
                        location.href = "/severError";
                    }
                 }
        });
    }
   
    
</script>
</body>
</html>